/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.inteligencia.stage.dataaccess.domain.hibernate;

import com.inteligencia.stage.dataaccess.base.hibernate.HibernateGenericDAO;
import com.inteligencia.stage.dataaccess.domain.PerfilEventoPersonaDAO;
import com.inteligencia.stage.dataaccess.model.TperfilEventoPersonaVO;
import java.io.Serializable;
import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author igorov
 */
public class HibernatePerfilEventoPersona extends HibernateGenericDAO<TperfilEventoPersonaVO, Integer> implements PerfilEventoPersonaDAO {

    public HibernatePerfilEventoPersona() {
        super(TperfilEventoPersonaVO.class);
    }

    @Override
    public TperfilEventoPersonaVO getByPersonaAndEvento(int idPersona, int idEvento) {
        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(TperfilEventoPersonaVO.class);
        detachedCriteria.
                add(Restrictions.eq("tpersona.ncodper", idPersona)).
                add(Restrictions.eq("tevento.ncodeve", idEvento));
         List<TperfilEventoPersonaVO> tperfilEventoPersonaVOs = listByCriteria(detachedCriteria);
         
         if(tperfilEventoPersonaVOs.size() > 0){
             return tperfilEventoPersonaVOs.get(0);
         }
         return null;
    }
    
}
